﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ITAP.Core.Modelling.Primitives;

using ITAP.Core.Calculations;
using ITAP.Core.Modelling;

namespace ITAP.ContourBuilder.Components
{
    [Serializable]
    public class ContourCommentLine : EndedContourComponent
    {
        public override void AcceptVisitor(IContourVisitor visitor)
        {
            visitor.Visit(this);
        }

        public override void MoveStartPoint(ModelVector offset)
        {
            ModelPoint destination = ModelCalculations.GetOffsetPoint(this.StartPoint, offset);
            (this.Primitive as IEndedPrimitive).MoveStartPoint(destination);
        }

        public override void MoveEndPoint(ModelVector offset)
        {
            ModelPoint destination = ModelCalculations.GetOffsetPoint(this.EndPoint, offset);
            (this.Primitive as IEndedPrimitive).MoveEndPoint(destination);
        }

        public override bool CanSelectByPoint(ModelPoint point)
        {
            double distance = this.Primitive.GetDistanceToPoint(point);
            if (distance < 20)
                return true;

            return false;
        }

        public override void SelectByPoint(ModelPoint point)
        {
            if(this.CanSelectByPoint(point))
                this.selected = true;
        }

        public override int Id
        {
            get
            {
                return -1;
            }
            set
            {
            }
        }

        public override bool HasBoundingBox
        {
            get
            {
                return false;
            }
            set
            {
            }
        }
    }
}
